﻿using SavoryBL;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApplication
{
    public partial class Offices_Agents : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
             SavoryUserDetails savoryUserDetails = new SavoryUserDetails();
            ((System.Web.UI.HtmlControls.HtmlGenericControl)Master.FindControl("divbreadcrum")).InnerHtml = @"<a href='default.aspx'>Home</a> >  <a href='menu.aspx'>Menu</a> > <a href='real_estate_search.aspx'>Real Estate Search</a> >  <a href='javascript:void();' onclick='history.go(-1);'>Real Estate Search Menu</a> > <span>Offices & Agents</span>";
           
            string Country = Request["co"];
            string City = Request["c"];
            DataSet ds = savoryUserDetails.GetOfficeandAgentsList(Country, City, "0");

            StringBuilder sOfficeListingHtml = new StringBuilder();

            if (ds != null && ds.Tables.Count > 0)
            {
                foreach (DataRow dr in ds.Tables[0].Rows)
                {                    
                    string str = @" <div class='search_result_list'>
                    	<div class='title'>
                        	<div class='inp_box fleft'><input type='checkbox' /></div>
                            <div class='heading_srl fleft'>
                            	<h3><a href='<%='Offices_Agents_Selected_Details.aspx?co='+ Request['co']+'&c='+Request['c'] %>'" + dr["OfficeAddress"].ToString() + @"</a> <span>(Office /Company Name)</span></h3>
                            	<h4>" + dr["FirstName"].ToString() + " " + dr["LastName"].ToString() + @"</h4>
                            </div>
                            <div class='clear'></div>
                        </div>
                        <table width='100%' border='0' cellspacing='0' cellpadding='0'>
                        	<tr>
                            	<td width='31%' rowspan='2'>
                                	<div class='listing_snap'>
                                    <img src='images/"+ dr["Image"].ToString() + @"' alt='' />
                                    </div>
                                </td>
                                <td width='15%' valign='top'>
                                	<div class='text-b_listing'><strong>
                                        Mobile [1]:<br />
                                        Office  [1]:<br />
                                        Fax:
                                    </strong></div>
                                </td>
                                <td valign='top'> 
                                	<div class='text-b_listing'>
                                    	" + dr["Mobile1"].ToString() + @"<br />
                                        " + dr["OfficeContactNo1"].ToString() + @"<br />
                                        " + dr["FAX"].ToString() + @"
                                </td>
                                <td align='center'>
                                    <a href='#' class='bl_light_btn_sec'>Detail Listing</a>
                                    <div style='height:10px;'></div>
                                    <a href='#' class='gr_light_btn_sec'>Save Contact</a>
                                </td>
                            </tr>
                           
                        </table>
                    
                    </div>";

                    sOfficeListingHtml.Append(str);
                }
            }
            div_AgentsList.InnerHtml = sOfficeListingHtml.ToString();
                       
        }
    }
}